package cn.jingzhuan.element.demo.view.util

import android.app.Activity
import android.util.Log
import android.widget.ImageView
import com.bumptech.glide.Glide


class ImageLoader {

    companion object {
        fun loadImage(imageView: ImageView, url: String?) {
            if (imageView.context is Activity) {
                if ((imageView.context as Activity).isFinishing) return
            }
            Log.i("ImageLoader","Image Url : ${url!!}")
            Glide.with(imageView.context).load(url).into(imageView)
        }

        fun loadBlurImage(imageView: ImageView,url: String?){
            val futureTarget = Glide.with(imageView.context)
                    .asBitmap()
                    .load(url)
                    .submit()
            val bitmap = futureTarget.get()
            BlurImageUtil.blur(bitmap,imageView)
        }
    }

}
